﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Gamev1
{
    public class HealthBar
    {
        private Texture2D Texture;
        private Vector2 Position;
        public double health;
        public Rectangle rectangle;

        public HealthBar(double health)
        {
            this.health = health;
        }

        public void LoadContent(ContentManager content)
        {
            Texture = content.Load<Texture2D>("Levels/HealthBar");
            rectangle = new Rectangle(0, 0, (int)health, Texture.Height);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Position, rectangle, Color.White);
        }

        public void Update(GameTime gameTime, Sprite sprite)
        {
            Position = new Vector2(sprite.Position.X - sprite.Texture.Width/2, sprite.Position.Y - 20);
        }

        public void Hit(int power)
        {
            rectangle.Width -= power;
        }
    }
}
